<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #root {
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
<div id="root">

</div>
<button onclick="fn()">点击改变颜色</button>
<script>
    function fn() {
        let r = Math.random() * 255
        let g = Math.random() * 255
        let b = Math.random() * 255
        root.style.background = "rgb(" + r + "," + g + "," + b + ")"
    }

</script>

</body>
</html>